import asyncio

from langchain_core.tools import tool, StructuredTool


def multi(a: int, b: int) -> int:
    return a * b


async def amulti(a: int, b: int) -> int:
    return a * b


async def main():
    struct_tool = StructuredTool.from_function(name="calculator", description="两个数相乘", func=multi, coroutine=amulti)
    print(struct_tool.invoke({"a": 2, "b": 3}))
    print(await struct_tool.ainvoke({"a": 4, "b": 5}))


asyncio.run(main())
